#include "StdAfx.h"
#include "ColorValue.h"

VAMPIRE_NAMESPACE_BEGIN

ColorValue::ColorValue( Real r, Real g, Real b, Real a )
{
	mData.r = r;
	mData.g = g;
	mData.b = b;
	mData.a = a;
}

ColorValue ColorValue::operator+( const ColorValue& rhs ) const
{
	return ColorValue(mData + rhs.mData);
}

Vampire::ColorValue ColorValue::operator+() const
{
	return *this;
}

ColorValue ColorValue::operator-( const ColorValue& rhs ) const
{
	return ColorValue(mData - rhs.mData);
}

ColorValue ColorValue::operator*( const Real& rhs ) const
{
	return ColorValue(mData * rhs);
}

Vampire::ColorValue ColorValue::operator/( const Real& rhs ) const
{
	return ColorValue(mData / rhs);
}

ColorValue& ColorValue::operator+=( const ColorValue& rhs )
{
	mData += rhs.mData;
	return *this;
}

ColorValue& ColorValue::operator-=( const ColorValue& rhs )
{
	mData -= rhs.mData;
	return *this;
}

ColorValue& ColorValue::operator*=( const Real& rhs )
{
	mData *= rhs;
	return *this;
}

ColorValue& ColorValue::operator/=( const Real& rhs )
{
	mData /= rhs;
	return *this;
}

void ColorValue::operator=( const ColorValue& rhs )
{
	mData = rhs.mData;
}

void ColorValue::operator=( const D3DXCOLOR& rhs )
{
	mData = rhs;
}

bool ColorValue::operator==( const ColorValue& rhs ) const
{
	return mData == rhs.mData ? true : false;
}

bool ColorValue::operator!=( const ColorValue& rhs ) const
{
	return mData == rhs.mData ? false : true;
}

Vampire::ColorValue ColorValue::operator-() const
{
	return ColorValue(-mData);
}

void ColorValue::adjustContrast( Real c )
{
	D3DXColorAdjustContrast(&(mData), &(mData), c);
}

Vampire::ColorValue ColorValue::getAdjustConstrastColor( Real c ) const
{
	ColorValue result;
	D3DXColorAdjustContrast(&(result.mData), &(mData), c);
	return result;
}

void ColorValue::adjustSaturation( Real s )
{
	D3DXColorAdjustSaturation(&(mData), &(mData), s);
}

Vampire::ColorValue ColorValue::getAdjustSaturationColor( Real s ) const
{
	ColorValue result;
	D3DXColorAdjustSaturation(&(result.mData), &(mData), s);
	return result;
}

void ColorValue::blendWith( const ColorValue& color )
{
	D3DXColorModulate(&(mData), &(mData), &(color.mData));
}

Vampire::ColorValue ColorValue::getBlendedColor( const ColorValue& color ) const
{
	ColorValue result;
	D3DXColorModulate(&(result.mData), &(mData), &(color.mData));
	return result;
}

void ColorValue::negative()
{
	D3DXColorNegative(&(mData), &(mData));
}

Vampire::ColorValue ColorValue::getNegative() const
{
	ColorValue result;
	D3DXColorNegative(&(result.mData), &(mData));
	return result;
}

Vampire::ColorValue ColorValue::add( const ColorValue& color ) const
{
	ColorValue result;
	D3DXColorAdd(&(result.mData), &mData, &(color.mData));
	return result;
}

Vampire::ColorValue ColorValue::subtract( const ColorValue& color ) const
{
	ColorValue result;
	D3DXColorSubtract(&(result.mData), &mData, &(color.mData));
	return result;
}

void ColorValue::scale( Real s )
{
	D3DXColorScale(&(mData), &(mData), s);
}

Vampire::ColorValue ColorValue::getLerpedColor( const ColorValue& color, Real s ) const
{
	ColorValue result;
	D3DXColorLerp(&(result.mData), &(mData), &(color.mData), s);
	return result;
}

Vampire::Vector4 ColorValue::toVector4() const
{
	return Vector4(D3DXVECTOR4(mData));
}

const ColorValue ColorValue::BLACK(0.0f, 0.0f, 0.0f, 1.0f);
const ColorValue ColorValue::WHITE(1.0f, 1.0f, 1.0f, 1.0f);
const ColorValue ColorValue::RED(1.0f, 0.0f, 0.0f, 1.0f);
const ColorValue ColorValue::GREEN(0.0f, 1.0f, 0.0f, 1.0f);
const ColorValue ColorValue::BLUE(0.0f, 0.0f, 1.0f, 1.0f);

VAMPIRE_NAMESPACE_END